home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 509 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.0 KB

  1. Path: news.kiss.de!news
  2. From: demler@kiss.de (Scott M. Demler)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: extern and static are they compatable
  5. Date: Fri, 05 Jan 1996 23:26:08 GMT
  6. Organization: KISS Kaiserslautern Internet Solution Service
  7. Message-ID: <4ckd75$i14@phobos.kiss.de>
  8. References: <4cedhf$g6i@cnn.cc.biu.ac.il> <ahicksDKM8Ap.FBp@netcom.com>
  9. NNTP-Posting-Host: dialin10.kiss.de
  10. X-Newsreader: Forte Free Agent 1.0.82
  11.  
  12. ahicks@netcom.com (Aaron Hicks at Netcom) wrote:
  13.  
  14. >Folks,
  15.  
  16. >  I'm working on a project which requires use to create large array 
  17. >( approximately 500 K bytes ) so we decided to make it static so it would  
  18. >not have be created each time the routines that use it are called.  We then
  19. >found out that we needed a nother program to acess this array so in the second
  20. >file we defined this array as a extern.  Now each time we compile and link 
  21. >the programs we get an error stating that the array is undefined.  The error
  22. >is displayed while linking.  After reading all I could find about extern 
  23. >I can not find any thing that says this is correct behavior.  I then changed 
  24. >the static decloration to a non static and the thing compiles with out a 
  25. >problem.  Now I'm wandering if any of the great mind on the net could 
  26. >enlighten me as to why the static declaration would cause this error.  
  27. >Below is a short part of the code that shows the declarations of the array.
  28.  
  29. >header_file.h
  30. >...
  31.  
  32. >typedef char   Bit_Fail_Array_Type[Row_Max][Column_Max_By_Byte][Sub_Array_Max];
  33. >...
  34.  
  35. >raster.c
  36. >...
  37. >/* Global declaration of the array to hold the failed bits */
  38. >static Bit_Fail_Array_Type bit_fail_array_table;
  39. >...
  40.  
  41. >raster_analysis.c
  42. >...
  43. >/* Declare the array that hold the failed bits to analysis */
  44. >extern Bit_Fail_Array_Type bit_fail_array_table;
  45. >...
  46.  
  47.  
  48. >Thanks in Advance and Happy New Year
  49.  
  50. >Aaron Hicks
  51. >ahicks@netcom.com
  52.  
  53. Aaron,
  54.  
  55. In brief...  Objects declared static can only be accessed from within the same
  56. 'source file'.  To access an object from somewhere outside of the source file
  57. you must declare it extern.
  58.  
  59. :-)  Scott M. Demler
  60.  
  61.